{include file="common/head"/}
<style>
    .layui-form-checkbox span{
        background-color: #807e7e;
    }
    .layui-form-checkbox:hover span{
        background-color: #807e7e;
    }
    .layui-form-checked span, .layui-form-checked:hover span{
        background-color: #5FB878;
    }
</style>
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>填写出借表</legend>
    </fieldset>
    <form class="layui-form layui-form-pane" lay-filter="form">


        <div class="layui-form-item">
            <label class="layui-form-label">出借人</label>
            <div class="layui-input-4">
                <input type="text" name="out_name" lay-verify="required" placeholder="{:lang('pleaseEnter')}出借人" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
            </div>
        </div>

        <!--<div class="layui-form-item">
            <label class="layui-form-label">借用人</label>
            <div class="layui-input-4">
                <input type="text" name="input_name" lay-verify="required" placeholder="{:lang('pleaseEnter')}借用人" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
            </div>
        </div>-->

        <div class="layui-form-item">
            <label class="layui-form-label">借用人</label>
            <div class="layui-input-4">
                <select lay-verify="required" name="input_id">
                    <option value="">请选择借用人</option>
                    {volist name="en" id="vo"}
                    <option value="{$vo.admin_id}">{$vo.username}</option>
                    {/volist}

                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">描述</label>
            <div class="layui-input-4">
                <textarea name="desc" placeholder="请输入内容" lay-verify="required" class="layui-textarea"></textarea>
            </div>
            <div class="layui-form-mid layui-word-aux">
                不超过250个汉字。
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">选择工具</label>
            <div class="layui-input-4" style="border: 1px solid #e6e6e6;min-height: 38px;" id="tool_list">

                {volist name="tools" id="vo"}
                    <input type="checkbox" name="tools_id" title="{$vo.title}({$vo.model})" value="{$vo.id}">
                {/volist}

            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <!--<input type="hidden" name="admin_id">-->
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
                <a href="{:url('listUI')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
            </div>
        </div>
    </form>
</div>
{include file="common/foot"/}
<script src="/public/static/common/js/jquery.2.1.1.min.js"></script>
<script>


    layui.use(['form', 'layer','upload'], function () {
        var form = layui.form, layer = layui.layer,$= layui.jquery;
        var info = null;

        form.val("form", info);
        if(info){
            $('#adPic').attr('src',info.avatar);
        }
        form.render();
        form.on('submit(submit)', function (data) {

            var ids = '';
            $('input[name=tools_id]:checked').each(function (k,v) {
                ids += $(this).val() + ',';
            });

            if(ids.length<=0){
                layer.msg('请选择工具',{icon:5});
                return;
            }
            loading =layer.load(1, {shade: [0.1,'#fff']});
            data.field.ids = ids;
            $.post('{:url("add")}', data.field, function (res) {
                layer.close(loading);
                if (res.code > 0) {
                    layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                        location.href = location.href;
                    });
                } else {
                    layer.msg(res.msg, {time: 1800, icon: 2});
                }
            });
        });
    });


</script>